/**
 * 线性方程组
 * 设有一个根，点 1, 2, 3 到根的距离分别是 a, b, c
 *
 * a + b = d_12
 * b + c = d_23
 * c + a = d_31
 *
 * 剩下的点全部接到根上即可
 */

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    vector<int> d(3);
    cin >> n;
    for (auto &e : d) cin >> e;
    int sum = accumulate(d.begin(), d.end(), 0);
    if (sum % 2 == 0) {
      vector<int> w(3);
      for (int i = 0; i < 3; ++i) w[i] = sum / 2 - d[(i + 1) % 3];
      vector<int> sw(w.begin(), w.end());
      sort(sw.begin(), sw.end());
      if (sw[0] >= 0 && sw[1] >= 1) {
        vector<pair<int, int>> edges;
        int num = 3;
        int center;
        if (sw[0] == 0)
          center = min_element(w.begin(), w.end()) - w.begin();
        else
          center = num++;

        for (int i = 0; i < 3; ++i) {
          int before = center;
          for (int j = 0; j < w[i] - 1; ++j) {
            edges.push_back({before, num});
            before = num++;
          }
          if (w[i] > 0) edges.push_back({before, i});
        }
        if (num <= n) {
          while (num < n) edges.push_back({center, num++});
          cout << "YES\n";
          for (auto [u, v] : edges) {
            cout << u + 1 << ' ' << v + 1 << '\n';
          }
          continue;
        }
      }
    }
    cout << "NO\n";
  }
}
